home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / harvard / dcu.bst < prev    next >
Text File  |  1994-06-16  |  25KB  |  1,352 lines

  1. % BibTeX standard bibliography style `dcu' (one of the harvard family)
  2.     % version 0.99a for BibTeX versions 0.99a or later, LaTeX version 2.09.
  3.     % Copyright (C) 1991, all rights reserved.
  4.     % Copying of this file is authorized only if either
  5.     % (1) you make absolutely no changes to your copy, including name, or
  6.     % (2) if you do make changes, you name it something other than
  7.     % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, abbrv.bst, agsm.bst,
  8.         % dcu.bst or kluwer.bst.
  9.     % This restriction helps ensure that all standard styles are identical.
  10.     % The file harvard.tex has the documentation for this style.
  11.  
  12. % ACKNOWLEDGEMENT:
  13. %   This document is a modified version of alpha.bst to which it owes much of
  14. %   its functionality.
  15.  
  16. % AUTHOR
  17. %   Peter Williams, Key Centre for Design Quality, Sydney University
  18. %   e-mail: peterw@archsci.arch.su.oz.au
  19.  
  20. ENTRY
  21.   { address
  22.     author
  23.     booktitle
  24.     chapter
  25.     edition
  26.     editor
  27.     howpublished
  28.     institution
  29.     journal
  30.     key
  31.     month
  32.     note
  33.     number
  34.     organization
  35.     pages
  36.     publisher
  37.     school
  38.     series
  39.     title
  40.     type
  41.     volume
  42.     year
  43.   }
  44.   { field.used etal.allowed etal.required }
  45.   { extra.label sort.label list.year }
  46.  
  47. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  48.  
  49. FUNCTION {init.state.consts}
  50. { #0 'before.all :=
  51.   #1 'mid.sentence :=
  52.   #2 'after.sentence :=
  53.   #3 'after.block :=
  54. }
  55.  
  56. STRINGS { s t f }
  57.  
  58. FUNCTION {output.nonnull}
  59. { 's :=
  60.   output.state mid.sentence =
  61.     { ", " * write$ }
  62.     { output.state after.block =
  63.     { add.period$ write$
  64.       newline$
  65.       "\newblock " write$
  66.     }
  67.     { output.state before.all =
  68.         'write$
  69.         { add.period$ " " * write$ }
  70.       if$
  71.     }
  72.       if$
  73.       mid.sentence 'output.state :=
  74.     }
  75.   if$
  76.   s
  77. }
  78.  
  79. FUNCTION {output}
  80. { duplicate$ empty$
  81.     'pop$
  82.     'output.nonnull
  83.   if$
  84. }
  85.  
  86. FUNCTION {output.check}
  87. { 't :=
  88.   duplicate$ empty$
  89.     { pop$ "empty " t * " in " * cite$ * warning$ }
  90.     'output.nonnull
  91.   if$
  92. }
  93.  
  94. FUNCTION {item.check}
  95. { 't :=
  96.   empty$
  97.     { "empty " t * " in " * cite$ * warning$ }
  98.     { skip$ }
  99.   if$
  100. }
  101.  
  102. FUNCTION {fin.entry}
  103. { add.period$
  104.   write$
  105.   newline$
  106. }
  107.  
  108. FUNCTION {new.block}
  109. { output.state before.all =
  110.     'skip$
  111.     { after.block 'output.state := }
  112.   if$
  113. }
  114.  
  115. FUNCTION {not}
  116. {   { #0 }
  117.     { #1 }
  118.   if$
  119. }
  120.  
  121. FUNCTION {and}
  122. {   'skip$
  123.     { pop$ #0 }
  124.   if$
  125. }
  126.  
  127. FUNCTION {or}
  128. {   { pop$ #1 }
  129.     'skip$
  130.   if$
  131. }
  132.  
  133. FUNCTION {field.or.null}
  134. { duplicate$ empty$
  135.     { pop$ "" }
  136.     'skip$
  137.   if$
  138. }
  139.  
  140. FUNCTION {emphasize}
  141. { duplicate$ empty$
  142.     { pop$ "" }
  143.     { "{\em " swap$ * "}" * }
  144.   if$
  145. }
  146.  
  147. FUNCTION {embolden}
  148. { duplicate$ empty$
  149.     { pop$ "" }
  150.     { "{\bf " swap$ * "}" * }
  151.   if$
  152. }
  153.  
  154. FUNCTION {quote}
  155. { duplicate$ empty$
  156.     { pop$ "" }
  157.     { "`" swap$ * "'" * }
  158.   if$
  159. }
  160.  
  161. INTEGERS { nameptr namesleft numnames }
  162.  
  163. FUNCTION {format.names}
  164. { 's :=
  165.   'f :=
  166.   #1 'nameptr :=
  167.   s num.names$ 'numnames :=
  168.   numnames 'namesleft :=
  169.     { namesleft #0 > }
  170.     { s nameptr f format.name$ 't :=
  171.       nameptr #1 >
  172.     { namesleft #1 >
  173.         { ", " * t * }
  174.         { t "others" =
  175.         { " et~al." * }
  176.         { " \harvardand\ " * t * }
  177.           if$
  178.         }
  179.       if$
  180.     }
  181.     't
  182.       if$
  183.       nameptr #1 + 'nameptr :=
  184.       namesleft #1 - 'namesleft :=
  185.     }
  186.   while$
  187. }
  188.  
  189. FUNCTION {format.authors}
  190. { author empty$
  191.     { "" }
  192.     { "{vv~}{ll}{, jj}{, f.}" author format.names }
  193.   if$
  194. }
  195.  
  196. FUNCTION {format.editors}
  197. { editor empty$
  198.     { "" }
  199.     { "{vv~}{ll}{, jj}{, f.}" editor format.names
  200.       editor num.names$ #1 >
  201.     { " (eds)" * }
  202.     { " (ed.)" * }
  203.       if$
  204.     }
  205.   if$
  206. }
  207.  
  208. FUNCTION {format.editors.reverse}
  209. { editor empty$
  210.     { "" }
  211.     { "{f.~}{vv~}{ll}{, jj}" editor format.names
  212.       editor num.names$ #1 >
  213.     { " (eds)" * }
  214.     { " (ed.)" * }
  215.       if$
  216.     }
  217.   if$
  218. }
  219.  
  220. FUNCTION {format.title}
  221. { title empty$
  222.     { "" }
  223.     { title "t" change.case$ }
  224.   if$
  225. }
  226.  
  227. FUNCTION {n.dashify}
  228. { 't :=
  229.   ""
  230.     { t empty$ not }
  231.     { t #1 #1 substring$ "-" =
  232.     { t #1 #2 substring$ "--" = not
  233.         { "--" *
  234.           t #2 global.max$ substring$ 't :=
  235.         }
  236.         {   { t #1 #1 substring$ "-" = }
  237.         { "-" *
  238.           t #2 global.max$ substring$ 't :=
  239.         }
  240.           while$
  241.         }
  242.       if$
  243.     }
  244.     { t #1 #1 substring$ *
  245.       t #2 global.max$ substring$ 't :=
  246.     }
  247.       if$
  248.     }
  249.   while$
  250. }
  251.  
  252. FUNCTION {format.btitle}
  253. { title emphasize
  254. }
  255.  
  256. FUNCTION {tie.or.space.connect}
  257. { duplicate$ text.length$ #3 <
  258.     { "~" }
  259.     { " " }
  260.   if$
  261.   swap$ * *
  262. }
  263.  
  264. FUNCTION {either.or.check}
  265. { empty$
  266.     'pop$
  267.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  268.   if$
  269. }
  270.  
  271. FUNCTION {format.bvolume}
  272. { volume empty$
  273.     { "" }
  274.     { "Vol." volume tie.or.space.connect
  275.       series empty$
  276.     'skip$
  277.     { " of " * series emphasize * }
  278.       if$
  279.       "volume and number" number either.or.check
  280.     }
  281.   if$
  282. }
  283.  
  284. FUNCTION {format.number.series}
  285. { volume empty$
  286.     { number empty$
  287.     { series field.or.null }
  288.     { output.state mid.sentence =
  289.         { "number" }
  290.         { "Number" }
  291.       if$
  292.       number tie.or.space.connect
  293.       series empty$
  294.         { "there's a number but no series in " cite$ * warning$ }
  295.         { " in " * series emphasize * }
  296.       if$
  297.     }
  298.       if$
  299.     }
  300.     { "" }
  301.   if$
  302. }
  303.  
  304. FUNCTION {format.edition}
  305. { edition empty$
  306.     { "" }
  307.     { output.state mid.sentence =
  308.     { edition "l" change.case$ " edn" * }
  309.     { edition "t" change.case$ " edn" * }
  310.       if$
  311.     }
  312.   if$
  313. }
  314.  
  315. INTEGERS { multiresult }
  316.  
  317. FUNCTION {multi.page.check}
  318. { 't :=
  319.   #0 'multiresult :=
  320.     { multiresult not
  321.       t empty$ not
  322.       and
  323.     }
  324.     { t #1 #1 substring$
  325.       duplicate$ "-" =
  326.       swap$ duplicate$ "," =
  327.       swap$ "+" =
  328.       or or
  329.     { #1 'multiresult := }
  330.     { t #2 global.max$ substring$ 't := }
  331.       if$
  332.     }
  333.   while$
  334.   multiresult
  335. }
  336.  
  337. FUNCTION {format.pages}
  338. { pages empty$
  339.     { "" }
  340.     { pages multi.page.check
  341.     { "pp.~" pages n.dashify * }
  342.     { "p.~" pages * }
  343.       if$
  344.     }
  345.   if$
  346. }
  347.  
  348. FUNCTION {format.vol.num.pages}
  349. { volume embolden field.or.null
  350.   number empty$
  351.     'skip$
  352.     { "(" number * ")" * *
  353.       volume empty$
  354.     { "there's a number but no volume in " cite$ * warning$ }
  355.     'skip$
  356.       if$
  357.     }
  358.   if$
  359.   pages empty$
  360.     'skip$
  361.     { duplicate$ empty$
  362.     { pop$ format.pages }
  363.     { ":~" * pages n.dashify * }
  364.       if$
  365.     }
  366.   if$
  367. }
  368.  
  369. FUNCTION {format.chapter.pages}
  370. { chapter empty$
  371.     'format.pages
  372.     { type empty$
  373.     { "chapter" }
  374.     { type "l" change.case$ }
  375.       if$
  376.       chapter tie.or.space.connect
  377.       pages empty$
  378.     'skip$
  379.     { ", " * format.pages * }
  380.       if$
  381.     }
  382.   if$
  383. }
  384.  
  385. FUNCTION {format.in.ed.booktitle}
  386. { booktitle empty$
  387.     { "" }
  388.     { editor empty$
  389.     { booktitle emphasize }
  390.     { "{\em in} " format.editors.reverse * ", " * booktitle emphasize * }
  391.       if$
  392.     }
  393.   if$
  394. }
  395.  
  396. FUNCTION {empty.misc.check}
  397. { author empty$ title empty$ howpublished empty$
  398.   month empty$ year empty$ note empty$
  399.   and and and and and
  400.   key empty$ not and
  401.     { "all relevant fields are empty in " cite$ * warning$ }
  402.     'skip$
  403.   if$
  404. }
  405.  
  406. FUNCTION {format.thesis.type}
  407. { type empty$
  408.     'skip$
  409.     { pop$
  410.       type "t" change.case$
  411.     }
  412.   if$
  413. }
  414.  
  415. FUNCTION {format.tr.number}
  416. { type empty$
  417.     { "Technical Report" }
  418.     'type
  419.   if$
  420.   number empty$
  421.     { "t" change.case$ }
  422.     { number tie.or.space.connect }
  423.   if$
  424. }
  425.  
  426. FUNCTION {format.article.crossref}
  427. { key empty$
  428.     { journal empty$
  429.     { "need key or journal for " cite$ * " to crossref " * crossref *
  430.       warning$
  431.       ""
  432.     }
  433.     { "in {\em " journal * "\/}" * " \cite{" * crossref * "}" *
  434.         }
  435.       if$
  436.     }
  437.     { " {\em in} \citeasnoun{" crossref * "}" * }
  438.   if$
  439. }
  440.  
  441. FUNCTION {format.book.crossref}
  442. { volume empty$
  443.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  444.       "in "
  445.     }
  446.     { "Vol." volume tie.or.space.connect
  447.       " of " *
  448.     }
  449.   if$
  450.   editor empty$
  451.   editor field.or.null author field.or.null =
  452.   or
  453.     { key empty$
  454.     { series empty$
  455.         { "need editor, key, or series for " cite$ * " to crossref " *
  456.           crossref * warning$
  457.           "" *
  458.         }
  459.         { "{\em " * series * "\/}" * " \cite{" * crossref * "}" *}
  460.       if$
  461.     }
  462.     { " \citeasnoun{" * crossref * "}" * }
  463.       if$
  464.     }
  465.     { " \citeasnoun{" * crossref * "}" * }
  466.   if$
  467. }
  468.  
  469. FUNCTION {format.incoll.inproc.crossref}
  470. { editor empty$
  471.   editor field.or.null author field.or.null =
  472.   or
  473.     {
  474.       key empty$
  475.     { booktitle empty$
  476.         { "need editor, key, or booktitle for " cite$ * " to crossref " *
  477.           crossref * warning$
  478.           ""
  479.         }
  480.         { "in {\em " booktitle * "\/}" * " \cite{" * crossref * "}" *}
  481.       if$
  482.     }
  483.     { " {\em in} \citeasnoun{" crossref * "}" * }
  484.       if$
  485.     }
  486.     {  " {\em in} \citeasnoun{" crossref * "}" * }
  487.   if$
  488.  
  489. }
  490.  
  491. INTEGERS { len }
  492.  
  493. FUNCTION {chop.word}
  494. { 's :=
  495.   'len :=
  496.   s #1 len substring$ =
  497.     { s len #1 + global.max$ substring$ }
  498.     's
  499.   if$
  500. }
  501.  
  502. INTEGERS { ind tsslen }
  503.  
  504. STRINGS { tss ret rss istr }
  505.  
  506. FUNCTION {replace.substring}{
  507.   'rss :=
  508.   'tss :=
  509.   'istr :=
  510.   "" 'ret :=
  511.   tss text.length$ 'tsslen :=
  512.   #1 'ind :=
  513.     { istr ind tsslen substring$ "" = not }
  514.     { istr ind tsslen substring$ tss =
  515.         { ret rss * 'ret :=
  516.           ind tsslen + 'ind :=
  517.         }
  518.         { ret istr ind #1 substring$ * 'ret :=
  519.           ind #1 + 'ind :=
  520.         }
  521.       if$
  522.     }
  523.   while$
  524.   ret
  525. }
  526.  
  527. FUNCTION {format.lab.names.abbr}
  528. { 's :=
  529.   s num.names$ 'numnames :=
  530.   numnames #1 >
  531.     { numnames #2 >
  532.     { s #1 "{vv~}{ll}" format.name$ " et~al." * }
  533.     { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  534.             { s #1 "{vv~}{ll}" format.name$ " et~al." * }
  535.         { s #1 "{vv~}{ll}" format.name$ " \harvardand\ " *
  536.               s #2 "{vv~}{ll}" format.name$ * 
  537.             }
  538.           if$
  539.         }
  540.       if$
  541.     }
  542.     { s #1 "{vv~}{ll}" format.name$ }
  543.   if$
  544. }
  545.  
  546. FUNCTION {format.lab.names.full}
  547. { 's :=
  548.   #1 'nameptr :=
  549.   s num.names$ 'numnames :=
  550.   numnames 'namesleft :=
  551.     { namesleft #0 > }
  552.     { s nameptr "{vv~}{ll}" format.name$ 't :=
  553.       nameptr #1 >
  554.     { namesleft #1 >
  555.         { ", " * t * }
  556.         { t "others" =
  557.         { " et~al." * }
  558.         { " \harvardand\ " * t * }
  559.           if$
  560.         }
  561.       if$
  562.     }
  563.     't
  564.       if$
  565.       nameptr #1 + 'nameptr :=
  566.       namesleft #1 - 'namesleft :=
  567.     }
  568.   while$
  569. }
  570.  
  571. INTEGERS { author.field editor.field organization.field title.field key.field }
  572.  
  573. FUNCTION {init.field.constants}
  574. { #0 'author.field :=
  575.   #1 'editor.field :=
  576.   #2 'organization.field :=
  577.   #3 'title.field :=
  578.   #4 'key.field :=
  579. }
  580.  
  581. FUNCTION {make.list.label}
  582. { author.field field.used =
  583.     { format.authors }
  584.     { editor.field field.used =
  585.         { format.editors }
  586.         { organization.field field.used =
  587.             { "The " #4 organization chop.word #3 text.prefix$ }
  588.             { title.field field.used =
  589.                 { format.btitle }
  590.                 { key.field field.used =
  591.                     { key #3 text.prefix$ }
  592.                     { "Internal error :001 on " cite$ * " label" * warning$ }
  593.                   if$
  594.                 }
  595.               if$
  596.             }
  597.           if$
  598.         }
  599.       if$
  600.     }
  601.   if$
  602. }
  603.  
  604. FUNCTION {make.full.label}
  605. { author.field field.used =
  606.     { author format.lab.names.full }
  607.     { editor.field field.used =
  608.         { editor format.lab.names.full }
  609.         { organization.field field.used =
  610.             { "The " #4 organization chop.word #3 text.prefix$ }
  611.             { title.field field.used =
  612.                 { format.btitle }
  613.                 { key.field field.used =
  614.                     { key #3 text.prefix$ }
  615.                     { "Internal error :001 on " cite$ * " label" * warning$ }
  616.                   if$
  617.                 }
  618.               if$
  619.             }
  620.           if$
  621.         }
  622.       if$
  623.     }
  624.   if$
  625. }
  626.  
  627. FUNCTION {make.abbr.label}
  628. { etal.allowed
  629.     { author.field field.used =
  630.         { author format.lab.names.abbr }
  631.         { editor.field field.used =
  632.             { editor format.lab.names.abbr }
  633.             { organization.field field.used =
  634.                 { "The " #4 organization chop.word #3 text.prefix$ }
  635.                 { title.field field.used =
  636.                     { format.btitle }
  637.                     { key.field field.used =
  638.                         { key #3 text.prefix$ }
  639.                         { "Internal error :001 on " cite$ * " label" * warning$}
  640.                       if$
  641.                     }
  642.                   if$
  643.                 }
  644.               if$
  645.             }
  646.           if$
  647.         }
  648.       if$
  649.     }
  650.     { make.full.label }
  651.   if$
  652. }
  653.  
  654. FUNCTION {output.bibitem}
  655. { newline$
  656.   etal.allowed        %%%XXX change
  657.   etal.required
  658.   and
  659.     {
  660.       "\harvarditem[" write$
  661.       make.abbr.label write$
  662.       "]{" write$
  663.     }
  664.     {
  665.       "\harvarditem{" write$
  666.     }
  667.   if$
  668.   make.full.label write$
  669.   "}{" write$
  670.   list.year write$
  671.   "}{" write$
  672.   cite$ write$
  673.   "}" write$
  674.   newline$
  675.   ""
  676.   before.all 'output.state :=
  677. }
  678.  
  679.  
  680. FUNCTION {list.label.output}
  681. { make.list.label " " * write$
  682. }
  683.  
  684. FUNCTION {article}
  685. { output.bibitem
  686.   list.label.output
  687.   " \harvardleft " list.year * "\harvardright " * output.nonnull
  688.   new.block
  689.   author "author" item.check
  690.   title.field field.used =
  691.     { skip$ }
  692.     { format.title "title" output.check }
  693.   if$
  694.   crossref missing$
  695.     { journal emphasize "journal" duplicate$ item.check
  696.       pages empty$
  697.         {
  698.           output
  699.         }
  700.         {
  701.           " " *
  702.           format.vol.num.pages * output
  703.         }
  704.       if$
  705.     }
  706.     { format.article.crossref output.nonnull
  707.       format.pages output
  708.     }
  709.   if$
  710.   new.block
  711.   note output
  712.   fin.entry
  713. }
  714.  
  715. FUNCTION {book}
  716. { output.bibitem
  717.   list.label.output
  718.   " \harvardleft " list.year * "\harvardright " * output.nonnull
  719.   new.block
  720.   author empty$
  721.     { editor "author and editor" item.check }
  722.     { crossref missing$
  723.     { "author and editor" editor either.or.check }
  724.     'skip$
  725.       if$
  726.     }
  727.   if$
  728.   title.field field.used =
  729.     { skip$ }
  730.     { format.btitle "title" output.check }
  731.   if$
  732.   crossref missing$
  733.     { format.bvolume output
  734.       format.number.series output
  735.       format.edition output
  736.       publisher "publisher" output.check
  737.       address output
  738.     }
  739.     { format.book.crossref output.nonnull
  740.       format.edition output
  741.     }
  742.   if$
  743.   new.block
  744.   note output
  745.   fin.entry
  746. }
  747.  
  748. FUNCTION {booklet}
  749. { output.bibitem
  750.   list.label.output
  751.   " \harvardleft " list.year * "\harvardright " * output.nonnull
  752.   new.block
  753.   title.field field.used =
  754.     { skip$ }
  755.     { format.title "title" output.check }
  756.   if$
  757.   howpublished output
  758.   address output
  759.   new.block
  760.   note output
  761.   fin.entry
  762. }
  763.  
  764. FUNCTION {inbook}
  765. { output.bibitem
  766.   list.label.output
  767.   " \harvardleft " list.year * "\harvardright " * output.nonnull
  768.   new.block
  769.   author empty$
  770.     { editor "author and editor" item.check }
  771.     { crossref missing$
  772.     { "author and editor" editor either.or.check }
  773.     'skip$
  774.       if$
  775.     }
  776.   if$
  777.   title.field field.used =
  778.     { skip$ }
  779.     { format.btitle "title" output.check }
  780.   if$
  781.   crossref missing$
  782.     { format.bvolume output
  783.       format.number.series output
  784.       format.edition output
  785.       publisher "publisher" output.check
  786.       address output
  787.     }
  788.     { format.book.crossref output.nonnull
  789.       format.edition output
  790.     }
  791.   if$
  792.   format.chapter.pages "chapter and pages" output.check
  793.   new.block
  794.   note output
  795.   fin.entry
  796. }
  797.  
  798. FUNCTION {incollection}
  799. { output.bibitem
  800.   list.label.output
  801.   " \harvardleft " list.year * "\harvardright " * output.nonnull
  802.   new.block
  803.   title.field field.used =
  804.     { skip$ }
  805.     { format.title "title" output.check }
  806.   if$
  807.   author "author" item.check
  808.   crossref missing$
  809.     { format.in.ed.booktitle "booktitle" output.check
  810.       format.edition output
  811.       format.bvolume output
  812.       format.number.series output
  813.       publisher "publisher" output.check
  814.       address output
  815.     }
  816.     { format.incoll.inproc.crossref output.nonnull
  817.     }
  818.   if$
  819.   format.chapter.pages output
  820.   new.block
  821.   note output
  822.   fin.entry
  823. }
  824.  
  825. FUNCTION {inproceedings}
  826. { output.bibitem
  827.   list.label.output
  828.   " \harvardleft " list.year * "\harvardright " * output.nonnull
  829.   new.block
  830.   title.field field.used =
  831.     { skip$ }
  832.     { format.title "title" output.check }
  833.   if$
  834.   author "author" item.check
  835.   crossref missing$
  836.     { format.in.ed.booktitle "booktitle" output.check
  837.       format.bvolume output
  838.       format.number.series output
  839.       address empty$
  840.     { organization output
  841.       publisher output
  842.     }
  843.     { organization output
  844.       publisher output
  845.       address output.nonnull
  846.     }
  847.       if$
  848.     }
  849.     { format.incoll.inproc.crossref output.nonnull
  850.     }
  851.   if$
  852.   format.pages output
  853.   new.block
  854.   note output
  855.   fin.entry
  856. }
  857.  
  858. FUNCTION {conference} { inproceedings }
  859.  
  860. FUNCTION {manual}
  861. { output.bibitem
  862.   list.label.output
  863.   " \harvardleft " list.year * "\harvardright " * output.nonnull
  864.   new.block
  865.   title.field field.used =
  866.     { skip$ }
  867.     { format.btitle "title" output.check }
  868.   if$
  869.   format.edition output
  870.   author empty$
  871.     { organization empty$
  872.     { address output
  873.     }
  874.     'skip$
  875.       if$
  876.     }
  877.     { organization output
  878.       address output
  879.     }
  880.   if$
  881.   new.block
  882.   note output
  883.   fin.entry
  884. }
  885.  
  886. FUNCTION {mastersthesis}
  887. { output.bibitem
  888.   list.label.output
  889.   " \harvardleft " list.year * "\harvardright " * output.nonnull
  890.   new.block
  891.   author "author" item.check
  892.   title.field field.used =
  893.     { skip$ }
  894.     { format.title emphasize "title" output.check }
  895.   if$
  896.   "Master's thesis" format.thesis.type output.nonnull
  897.   school "school" output.check
  898.   address output
  899.   new.block
  900.   note output
  901.   fin.entry
  902. }
  903.  
  904. FUNCTION {misc}
  905. { output.bibitem
  906.   list.label.output
  907.   " \harvardleft " list.year * "\harvardright " * output.nonnull
  908.   new.block
  909.   title.field field.used =
  910.     { skip$ }
  911.     { format.title output }
  912.   if$
  913.   howpublished output
  914.   new.block
  915.   note output
  916.   fin.entry
  917.   empty.misc.check
  918. }
  919.  
  920. FUNCTION {phdthesis}
  921. { output.bibitem
  922.   list.label.output
  923.   " \harvardleft " list.year * "\harvardright " * output.nonnull
  924.   new.block
  925.   author "author" item.check
  926.   title.field field.used =
  927.     { skip$ }
  928.     { format.btitle "title" output.check }
  929.   if$
  930.   "PhD thesis" format.thesis.type output.nonnull
  931.   school "school" output.check
  932.   address output
  933.   new.block
  934.   note output
  935.   fin.entry
  936. }
  937.  
  938. FUNCTION {proceedings}
  939. { output.bibitem
  940.   list.label.output
  941.   " \harvardleft " list.year * "\harvardright " * output.nonnull
  942.   new.block
  943.   title.field field.used =
  944.     { skip$ }
  945.     { format.btitle "title" output.check }
  946.   if$
  947.   format.bvolume output
  948.   format.number.series output
  949.   address empty$
  950.     { editor empty$
  951.     { skip$ }
  952.     { organization output
  953.     }
  954.       if$
  955.       publisher output
  956.     }
  957.     { editor empty$
  958.     'skip$
  959.     { organization output }
  960.       if$
  961.       publisher output
  962.       address output.nonnull
  963.     }
  964.   if$
  965.   new.block
  966.   note output
  967.   fin.entry
  968. }
  969.  
  970. FUNCTION {techreport}
  971. { output.bibitem
  972.   list.label.output
  973.   " \harvardleft " list.year * "\harvardright " * output.nonnull
  974.   new.block
  975.   author "author" item.check
  976.   title.field field.used =
  977.     { skip$ }
  978.     { format.title "title" output.check }
  979.   if$
  980.   format.tr.number emphasize output.nonnull
  981.   institution "institution" output.check
  982.   address output
  983.   new.block
  984.   note output
  985.   fin.entry
  986. }
  987.  
  988. FUNCTION {unpublished}
  989. { output.bibitem
  990.   list.label.output
  991.   " \harvardleft " list.year * "\harvardright " * output.nonnull
  992.   new.block
  993.   author "author" item.check
  994.   title.field field.used =
  995.     { skip$ }
  996.     { format.title "title" output.check }
  997.   if$
  998.   note "note" output.check
  999.   fin.entry
  1000. }
  1001.  
  1002. FUNCTION {default.type} { misc }
  1003.  
  1004. MACRO {jan} {"January"}
  1005.  
  1006. MACRO {feb} {"February"}
  1007.  
  1008. MACRO {mar} {"March"}
  1009.  
  1010. MACRO {apr} {"April"}
  1011.  
  1012. MACRO {may} {"May"}
  1013.  
  1014. MACRO {jun} {"June"}
  1015.  
  1016. MACRO {jul} {"July"}
  1017.  
  1018. MACRO {aug} {"August"}
  1019.  
  1020. MACRO {sep} {"September"}
  1021.  
  1022. MACRO {oct} {"October"}
  1023.  
  1024. MACRO {nov} {"November"}
  1025.  
  1026. MACRO {dec} {"December"}
  1027.  
  1028. MACRO {acmcs} {"ACM Computing Surveys"}
  1029.  
  1030. MACRO {acta} {"Acta Informatica"}
  1031.  
  1032. MACRO {cacm} {"Communications of the ACM"}
  1033.  
  1034. MACRO {ibmjrd} {"IBM Journal of Research and Development"}
  1035.  
  1036. MACRO {ibmsj} {"IBM Systems Journal"}
  1037.  
  1038. MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
  1039.  
  1040. MACRO {ieeetc} {"IEEE Transactions on Computers"}
  1041.  
  1042. MACRO {ieeetcad}
  1043.  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
  1044.  
  1045. MACRO {ipl} {"Information Processing Letters"}
  1046.  
  1047. MACRO {jacm} {"Journal of the ACM"}
  1048.  
  1049. MACRO {jcss} {"Journal of Computer and System Sciences"}
  1050.  
  1051. MACRO {scp} {"Science of Computer Programming"}
  1052.  
  1053. MACRO {sicomp} {"SIAM Journal on Computing"}
  1054.  
  1055. MACRO {tocs} {"ACM Transactions on Computer Systems"}
  1056.  
  1057. MACRO {tods} {"ACM Transactions on Database Systems"}
  1058.  
  1059. MACRO {tog} {"ACM Transactions on Graphics"}
  1060.  
  1061. MACRO {toms} {"ACM Transactions on Mathematical Software"}
  1062.  
  1063. MACRO {toois} {"ACM Transactions on Office Information Systems"}
  1064.  
  1065. MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
  1066.  
  1067. MACRO {tcs} {"Theoretical Computer Science"}
  1068.  
  1069. READ
  1070.  
  1071. EXECUTE {init.field.constants}
  1072.  
  1073. FUNCTION {sortify}
  1074. { purify$
  1075.   "l" change.case$
  1076. }
  1077.  
  1078. FUNCTION {sortify.names}
  1079. { " \harvardand\ " " " replace.substring
  1080.   " et~al." " zzz" replace.substring
  1081.   sortify
  1082. }
  1083.  
  1084. FUNCTION {author.key.label}
  1085. { author empty$
  1086.     { key empty$
  1087.     { title.field 'field.used := }
  1088.     { key.field 'field.used := }
  1089.       if$
  1090.     }
  1091.     { author.field 'field.used := }
  1092.   if$
  1093. }
  1094.  
  1095. FUNCTION {author.editor.key.label}
  1096. { author empty$
  1097.     { editor empty$
  1098.     { key empty$
  1099.         { title.field 'field.used := }
  1100.         { key.field 'field.used := }
  1101.       if$
  1102.       }
  1103.     { editor.field 'field.used := }
  1104.       if$
  1105.     }
  1106.     { author.field 'field.used := }
  1107.   if$
  1108. }
  1109.  
  1110. FUNCTION {author.key.organization.label}
  1111. { author empty$
  1112.     { key empty$
  1113.     { organization empty$
  1114.         { title.field 'field.used := }
  1115.         { organization.field 'field.used := }
  1116.       if$
  1117.     }
  1118.     { key.field 'field.used := }
  1119.       if$
  1120.     }
  1121.     { author.field 'field.used := }
  1122.   if$
  1123. }
  1124.  
  1125. FUNCTION {editor.key.organization.label}
  1126. { editor empty$
  1127.     { key empty$
  1128.     { organization empty$
  1129.         { title.field 'field.used := }
  1130.         { organization.field 'field.used := }
  1131.       if$
  1132.     }
  1133.     { key.field 'field.used := }
  1134.       if$
  1135.     }
  1136.     { editor.field 'field.used := }
  1137.   if$
  1138. }
  1139.  
  1140. FUNCTION {sort.format.title}
  1141. { 't :=
  1142.   "A " #2
  1143.     "An " #3
  1144.       "The " #4 t chop.word
  1145.     chop.word
  1146.   chop.word
  1147.   sortify
  1148.   #1 global.max$ substring$
  1149. }
  1150.  
  1151. FUNCTION {calc.label}
  1152. { make.abbr.label
  1153.   title.field field.used =
  1154.     { sort.format.title }
  1155.     { sortify.names }
  1156.   if$
  1157.   year field.or.null purify$ #-1 #4 substring$ sortify
  1158.   *
  1159.   'sort.label :=
  1160. }
  1161.  
  1162. FUNCTION {preliminaries} %%%XXX change
  1163. { type$ "book" =
  1164.   type$ "inbook" =
  1165.   or
  1166.     'author.editor.key.label
  1167.     { type$ "proceedings" =
  1168.     'editor.key.organization.label
  1169.     { type$ "manual" =
  1170.         'author.key.organization.label
  1171.         'author.key.label
  1172.       if$
  1173.     }
  1174.       if$
  1175.     }
  1176.   if$
  1177.   author.field field.used = %%%XXX change
  1178.     {
  1179.       author num.names$ #2 >
  1180.         { #1 }
  1181.         { #0 }
  1182.       if$
  1183.       'etal.required :=
  1184.     }
  1185.     {
  1186.       editor.field field.used = 
  1187.         {
  1188.           editor num.names$ #2 >
  1189.             { #1 }
  1190.             { #0 }
  1191.           if$
  1192.         }
  1193.         { #0 }
  1194.       if$
  1195.       'etal.required :=
  1196.     }
  1197.   if$
  1198.   #1 'etal.allowed :=
  1199. }
  1200.  
  1201. FUNCTION {first.presort}
  1202. { calc.label
  1203.   sort.label
  1204.   title.field field.used =
  1205.     { skip$ }
  1206.     { "    "
  1207.       *
  1208.       make.list.label sortify.names
  1209.       *
  1210.       "    "
  1211.       *
  1212.       title field.or.null
  1213.       sort.format.title
  1214.       *
  1215.     }
  1216.   if$
  1217.   #1 entry.max$ substring$
  1218.   'sort.key$ :=
  1219. }
  1220.  
  1221. ITERATE {preliminaries}
  1222.  
  1223. ITERATE {first.presort}
  1224.  
  1225. SORT
  1226.  
  1227. STRINGS { last.sort.label next.extra last.full.label }
  1228.  
  1229. INTEGERS { last.extra.num last.etal.allowed }
  1230.  
  1231. FUNCTION {initialize.confusion}
  1232. { #0 int.to.chr$ 'last.sort.label :=
  1233.   #0 int.to.chr$ 'last.full.label :=
  1234.   #1 'last.etal.allowed :=
  1235. }
  1236.  
  1237. FUNCTION {confusion.pass}
  1238. { last.sort.label sort.label =
  1239.     { last.etal.allowed 
  1240.         { last.full.label make.full.label sortify.names =
  1241.             { skip$ }
  1242.             { #0 'etal.allowed :=
  1243.               #0 'last.etal.allowed :=
  1244.             }
  1245.           if$
  1246.         }
  1247.         { #0 'etal.allowed := }
  1248.       if$
  1249.     }
  1250.     { sort.label 'last.sort.label :=
  1251.       make.full.label sortify.names 'last.full.label :=
  1252.       #1 'last.etal.allowed :=
  1253.     }
  1254.   if$
  1255. }
  1256.  
  1257. EXECUTE {initialize.confusion}
  1258.  
  1259. ITERATE {confusion.pass}
  1260.  
  1261. EXECUTE {initialize.confusion}
  1262.  
  1263. REVERSE {confusion.pass}
  1264.  
  1265. FUNCTION {initialize.last.extra.num}
  1266. { #0 int.to.chr$ 'last.sort.label :=
  1267.   "" 'next.extra :=
  1268.   #0 'last.extra.num :=
  1269. }
  1270.  
  1271. FUNCTION {forward.pass}
  1272. { last.sort.label sort.label =
  1273.     { last.extra.num #1 + 'last.extra.num :=
  1274.       last.extra.num int.to.chr$ 'extra.label :=
  1275.     }
  1276.     { "a" chr.to.int$ 'last.extra.num :=
  1277.       "" 'extra.label :=
  1278.       sort.label 'last.sort.label :=
  1279.     }
  1280.   if$
  1281. }
  1282.  
  1283. FUNCTION {reverse.pass}
  1284. { next.extra "b" =
  1285.     { "a" 'extra.label := }
  1286.     'skip$
  1287.   if$
  1288.   year empty$
  1289.     { "n.d." extra.label * 'list.year := }
  1290.     { year extra.label * 'list.year := }
  1291.   if$
  1292.   extra.label 'next.extra :=
  1293. }
  1294.  
  1295. ITERATE {first.presort}
  1296.  
  1297. SORT
  1298.  
  1299. EXECUTE {initialize.last.extra.num}
  1300.  
  1301. ITERATE {forward.pass}
  1302.  
  1303. REVERSE {reverse.pass}
  1304.  
  1305. FUNCTION {second.presort}
  1306. { make.list.label
  1307.   title.field field.used =
  1308.     { sort.format.title }
  1309.     { sortify.names }
  1310.   if$
  1311.   "    "
  1312.   *
  1313.   list.year field.or.null sortify
  1314.   *
  1315.   "    "
  1316.   *
  1317.   title.field field.used =
  1318.     { skip$ }
  1319.     { title field.or.null
  1320.       sort.format.title
  1321.       *
  1322.     }
  1323.   if$
  1324.   #1 entry.max$ substring$
  1325.   'sort.key$ :=
  1326. }
  1327.  
  1328. ITERATE {second.presort}
  1329.  
  1330. SORT
  1331.  
  1332. FUNCTION {begin.bib}
  1333. { preamble$ empty$
  1334.     'skip$
  1335.     { preamble$ write$ newline$ }
  1336.   if$
  1337.   "\begin{thebibliography}{xx}" write$ newline$
  1338. }
  1339.  
  1340. EXECUTE {begin.bib}
  1341.  
  1342. EXECUTE {init.state.consts}
  1343.  
  1344. ITERATE {call.type$}
  1345.  
  1346. FUNCTION {end.bib}
  1347. { newline$
  1348.   "\end{thebibliography}" write$ newline$
  1349. }
  1350.  
  1351. EXECUTE {end.bib}
  1352.